-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[ADT] Make getAutoSenseRadix
in StringRef
global
#152503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-llvm-support @llvm/pr-subscribers-llvm-adt Author: Ilia Kuklin (kuilpd) ChangesNeeded in #152308 Full diff: https://github.com/llvm/llvm-project/pull/152503.diff 2 Files Affected:
diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h
index 0ced1c0379a3b..16aca4d45892d 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -38,6 +38,8 @@ namespace llvm {
LLVM_ABI bool getAsSignedInteger(StringRef Str, unsigned Radix,
long long &Result);
+ LLVM_ABI unsigned getAutoSenseRadix(StringRef &Str);
+
LLVM_ABI bool consumeUnsignedInteger(StringRef &Str, unsigned Radix,
unsigned long long &Result);
LLVM_ABI bool consumeSignedInteger(StringRef &Str, unsigned Radix,
diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp
index dc758785e40d5..b6a2f8aeadccf 100644
--- a/llvm/lib/Support/StringRef.cpp
+++ b/llvm/lib/Support/StringRef.cpp
@@ -385,7 +385,7 @@ size_t StringRef::count(StringRef Str) const {
return Count;
}
-static unsigned GetAutoSenseRadix(StringRef &Str) {
+unsigned llvm::getAutoSenseRadix(StringRef &Str) {
if (Str.empty())
return 10;
@@ -410,7 +410,7 @@ bool llvm::consumeUnsignedInteger(StringRef &Str, unsigned Radix,
unsigned long long &Result) {
// Autosense radix if not specified.
if (Radix == 0)
- Radix = GetAutoSenseRadix(Str);
+ Radix = getAutoSenseRadix(Str);
// Empty strings (after the radix autosense) are invalid.
if (Str.empty()) return true;
@@ -509,7 +509,7 @@ bool StringRef::consumeInteger(unsigned Radix, APInt &Result) {
// Autosense radix if not specified.
if (Radix == 0)
- Radix = GetAutoSenseRadix(Str);
+ Radix = getAutoSenseRadix(Str);
assert(Radix > 1 && Radix <= 36);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to add a unit test too now that this is a public method, but I won't block over this
✅ With the latest revision this PR passed the C/C++ code formatter. |
(We don't usually use "NFC" for functionality that's tested/testable - though I get where you're coming from, that this doesn't change the behavior of any LLVM program - but I'd probably leave off the NFC in this case (& I'm glad to see the test added - I think that's necessary for changes like this)) |
getAutoSenseRadix
in StringRef
globalgetAutoSenseRadix
in StringRef
global
Needed in #152308